import axios from '@/utils/request'
import { setToken } from '@/utils/storage'
import { LOGIN_SETTOKEN } from '../actionTypes'

export const getToken = (value) => {
  return async (dispatch) => {
    const res = await axios({
      method: 'POST',
      url: 'authorizations',
      data: value
    })
    dispatch({ type: LOGIN_SETTOKEN, payload: res.data.token })
    setToken(res.data.token)
  }
}
